
/* Generated by Interface Builder */

#import "GraphController.h"
#import "GraphView.h"
#import <appkit/appkit.h>
#import <math.h>

void function1(detail, anArray)
   int detail;
   bigArray anArray;
{
	int i=0,j=0;
	float count=0.0;
	
	count=PI/detail*4;
	for (i=0; i < detail; i++)
	{
		for (j=0; j < detail; j++)
		{
			/*anArray[i][j]=(float) sin(i*count)*cos(j*count);
			*/
		}
	}
}

void function2(detail, anArray)
   int detail;
   bigArray anArray;
{
}

void function3(detail, anArray)
   int detail;
   bigArray anArray;
{
}





@implementation GraphController

- init
{
	[super init];
	curGraph=1;
	[self writeDetail:10];
	[self writeSize:200];
	[self writeTheta:0];
	[self writePhi:0];
	graphArray = (bigArray) malloc(sizeof(float)*detail*detail);
	function1(detail, graphArray);
	[thetaDisplayPtr setIntValue:[self readTheta]];
	[phiDisplayPtr setIntValue:[self readPhi]];
	return self;
}

- appDidInit: sender
{
	[[graphViewPtr window] makeKeyAndOrderFront:self];
	return self;
}


- selectFunction:sender
{
	curGraph = [sender selectedCol];
	switch (curGraph)
	{
		case 1 : function1(detail, graphArray);
		case 2 : function2(detail, graphArray);
		case 3 : function3(detail, graphArray);
	}
	return self;
}

- changePerspective: sender
{
	[self writePerspective: [sender floatValue]];
	[graphViewPtr display];
	return self;
}

- slideThetaSlider: (int)val
{
	[thetaSliderPtr setIntValue:val];
	return self;
}

- slidePhiSlider: (int)val
{
	[phiSliderPtr setIntValue:val];
	return self;
}

- updateThetaSlider: sender
{
	[self writeTheta:[sender intValue]];
	[graphViewPtr display];
	return self;
}
- updatePhiSlider: sender
{
	[self writePhi:[sender intValue]];
	[graphViewPtr display];
	return self;
}
- updateSizeSlider: sender
{
	[self writeSize:[sender intValue]];
	[graphViewPtr display];
	return self;
}
- updateDetailSlider: sender
{
	[self writeDetail:[sender intValue]*2];
	[graphViewPtr display];
	return self;
}

- (int) readCurGraph
{
	return curGraph;
}

- (int) readSize
{
	return scale;
}

- (int) readDetail
{
	return detail;
}

- (int) readTheta
{
	return theta;
}

- (int) readPhi
{
	return phi;
}

- (float) readPerspective
{
	return perspective;
}

- (bigArray) readGraphArray
{
	return graphArray;
}

- writeCurGraph: (int) val
{
	curGraph = val;
	return self;
}

- writeSize: (int) val
{
	scale=val;
	[sizeDisplayPtr setIntValue:val];
	return self;
}

- writeDetail: (int) val
{
	detail = val;
	[detailDisplayPtr setIntValue:val];
	return self;
}

- writeTheta:(int) val
{
	theta = val;
	[thetaDisplayPtr setIntValue:val];
	return self;
}

- writePhi:(int) val;
{
	phi = val;
	[phiDisplayPtr setIntValue:val];
	return self;
}

- writePerspective:(float) val
{
	perspective = val;
	return self;
}
@end
